package DAO.imp;

import DAO.UserDao;
import POJO.UserEntity;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

/**
 * Created by hui on 2017/6/12.
 */
public class ImpUserDAO extends HibernateDaoSupport implements UserDao {
    public UserEntity checkUser(UserEntity user) {
        List<UserEntity> list = (List<UserEntity>) this.getHibernateTemplate().find("from  UserEntity ",user);
        if(list!=null&&!list.isEmpty()&&list.size()==1){
            return list.get(0);
        }
        return null;
    }

    public void addUser(UserEntity user) {
        this.getHibernateTemplate().save(user);
    }

    public List<UserEntity> queryAllUser() {
        return (List<UserEntity>) getHibernateTemplate().find("from UserEntity ");
    }
}
